<?php
namespace wow\controller;

use gnomephp\mvc\CoreController;
use \gnomephp\doctrine\Doctrine;
use \wow\controller\Application;

use wow\model as m;
class Installer extends CoreController{
	
	
	public function install(){
		
		Doctrine::load();
		
		$schemaTool = new \Doctrine\ORM\Tools\SchemaTool(Doctrine::getEM());
		
		$schemaTool->dropDatabase();
		
		
		$metadatas = Doctrine::getEM()->getMetadataFactory()->getAllMetadata();
		
		$schemaTool->createSchema($metadatas);
		
		$this->fixtures();
		die("Install successful.");
		
	}
	
	
	public function fixtures(){
		
		
		$o = new m\Page(m\Page::PAGE_MAIN_PAGE, '<h2>Click on this text to edit it</h2><h2>Welcome</h2><p>Login on a GM account to change this ( with gm level > 2 )</p>', 3);
		Doctrine::getEM()->persist($o);
		
		
		
		Doctrine::getEM()->flush();
		
	}
	
	
	
}